package test.enba.mq.producer.controller.rabbitmq.header;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HeadersExchangeProducer {

  @Autowired private RabbitTemplate rabbitTemplate;

  public void sendMessage(String message) {
    MessageProperties properties = new MessageProperties();
    properties.setHeader("type", "message");
    properties.setHeader("format", "text");
    properties.setHeader("format2", "text2");
    Message msg = new Message(message.getBytes(), properties);

    rabbitTemplate.send("headers-exchange", "", msg);
  }
}
